package org.langqiao.algorithm;
/*
 * 圆周率/2=1+1/3+1/3*2/5+1/3*2/5*3/7+1/3*2/5*3/7*4/9,利用此公式计算圆周率
 */
public class PI{
	
	public static void main(String[] args) {
		
		double x = 1;
		double y = 1;
		int a = 1;
		int b = 3;
		double le = 0;
		while(y > le-15){
//			y=a++/(double)(b+=2);
			y=y*a/b;
			x+=y;
			a++;
			b+=2;
		}
		System.out.println("圆周率为："+x*2);
	}
}
